$(document).on("click", "#login", function () {
    var mobile = $('#declare-contact-phone').val();
    if (!IsMobile(mobile)) {
        Common.TipTop($("#login"), "手机格式输入有误", "-100px");
        return false;
    }
    if(mobile == ''){
        Common.TipTop($("#login"), "手机号码不能为空", "-100px");
        return false;
    }
    var mobileCode = $('#mobileCode').val();
    if(mobileCode == ''){
        Common.TipTop($("#login"), "验证码不能为空", "-100px");
        return false;
    }
    var data = {'mobile': mobile, 'code': mobileCode}
    getdata(host + "userproject/findProjectByAccount", data,
        function(res){
            var data = res.res.data;
            if(res.res.code == 40000){
                sessionStorage.setItem("kid", data.kid);
                if(data.userRole == "参赛者"){
                    sessionStorage.setItem("declarationMobile", data.proposerMobile);
                    sessionStorage.setItem("shenbaoUrl", data.shenbaoUrl);
                    sessionStorage.setItem("shenbaoPersionUrl", data.shenbaoPersionUrl);
                    sessionStorage.setItem("isRegEnterprice", data.isRegEnterprice);
                    if(data.isAgreement != "是"){
                        window.location.href = $().AbsUrlParse("/web/page/agreementPage?isAgreement=" + data.isAgreement);
                    } else {
		            if(data.ruleState == '初赛'){
		                // 初赛  跳转初赛页面check
		                //if(data.auditState != "审核通过"){
		                    window.location.href = $().AbsUrlParse("/web/page/indextwo");
		                    // window.location.href = "index-two.html";
		                //} else {
		                   // window.location.href = $().AbsUrlParse("/web/page/check?auditState=" + data.auditState + "&auditReason=" + data.auditReason);
		                    // window.location.href = "check.html?auditState=" + data.auditState;
		                //}
		            } else {
		                // 复赛  跳转复赛页面repeat-check
		                if(data.auditStateSecond == "审核通过"){
		                     window.location.href = $().AbsUrlParse("/web/page/repeatCheck?totalScore=" + data.totalScore + '&enterOrder=' + data.enterOrder);
		                    //  window.location.href = "repeat-check.html?totalScore=" + data.totalScore + '&enterOrder=' + data.enterOrder;
		                } else {
		                     window.location.href = $().AbsUrlParse("/web/page/check?auditState=" + data.auditStateSecond + '&auditReason=' + data.auditReasonSecond);
		                    //  window.location.href = "check.html?auditState=" + data.audit_state_second + '&auditReason='+ data.audit_reason_second;
		                }
		            }
                      }
                } else {
                    sessionStorage.setItem("declarationMobile", data.phone);
                    // 大众评委或投资机构  跳转申报列表declare-list页面
                    window.location.href = $().AbsUrlParse("/web/page/declareList?userRole=" + data.userRole + '&id=' + data.id);
                    // window.location.href = "declare-list.html?userRole=" + data.userRole + '&id=' + data.id;
                }
            } else {
                Common.TipTop($("#login"), res.res.msg , "-100px");
                return false;
            }
        }
    );
})
